import { RobCityStepPanelBase } from "../RobCityStepPanelBase";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { Language } from "../../../../../extend/language/Language";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { RobCityStepOneRankRenderer } from "./RobCityStepOneRankRenderer";
import { RuleExplainButton } from "../../common/button/RuleExplainButton";
import { CopyConfig } from "../../../resource/CopyConfig";
import { Cache } from "../../../cache/Cache";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { ECopyType } from "../../../../../Message/Public/ECopyType";
import { GameProxy } from "../../../mvc/GameProxy";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { RemainTimeTool } from "../../award/RemainTimeTool";
import { HighlightManager } from "../../../manager/HighlightManager";
import { GLoadedButton } from "../../../../../com/mui/controls/GLoadedButton";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
import { PageSelecter } from "../../common/pageSelect/PageSelecter";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
type int = number;
//class RobCityStepOnePanel
    
    export  class RobCityStepOnePanel extends RobCityStepPanelBase
    {
        constructor()
        {
            super();
            this.initUI();
            return;
        }

        /* internal  */initUI(): void
        {
            ObjCreate.createBg(0, 0, 804, 160, this);
            ObjCreate.createGImageBitmap(ImagesConst.RobCityBg1, 1, 2, this);
            ObjCreate.createBg(0, 163, 804, 223, this);
            this._signBtn = ObjCreate.createGLoadedButton(ResFileConst.RobCitySignUpBtn, 353, 28, 97, 50, this);
            this._signBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onSignBtnClick);
            this._myRank = ObjCreate.createGTextField("", 200, 100, 404, 20, this, GlobalStyle.getTextFormatCenter(GlobalStyle.textFormat6));
            this._statusLabel = ObjCreate.createGTextField("", 200, 120, 404, 20, this, GlobalStyle.getTextFormatCenter(GlobalStyle.textFormat6));
            ObjCreate.createFireTip(Language.getString(60929), 205, 167, this, true);
            ObjCreate.createBg(20, 195, 770, 2, this, ImagesConst.SplitLine);
            this._myGuildRank = ObjCreate.createGTextField("", 590, 174, 200, 20, this, new GTextFormat(FontUtil.songtiName, 12, 16776960, null, null, null, null, null, flash.text.TextFormatAlign.RIGHT));
            this._list = ObjCreate.createTileList(10, 203, 790, 156, this);
            this._list.rowHeight = 76;
            this._list.columnWidth = 157;
            this._list.setStyle("cellRenderer", RobCityStepOneRankRenderer);
            this._pageSelec = ObjCreate.createPageSelecter(360, 360, this);
            this._pageSelec.addEventListener(flash.events.Event.CHANGE, this.onPageSelecterChangeHandler);
            var loc1=new RuleExplainButton();
            loc1.tooltipText = CopyConfig.instance.getRobCopyDesc(3);
            loc1.x = 514;
            loc1.y = 122;
            this.addChild(loc1);
            return;
        }

        /* internal  */onSignBtnClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (Cache.instance.robCity.robCityCopyOneInfo && Cache.instance.robCity.robCityCopyOneInfo.hasOpen) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.RobCity_doEnterCopy, ECopyType._ECopyRobCityOne));
            }
            else 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.GuildOpenCopyWindow, ECopyType._ECopyRobCityOne));
            }
            return;
        }

        /* internal  */onPageSelecterChangeHandler(arg1): void
        {
            this.getRankingList();
            return;
        }

        public getRankingList(): void
        {
            this._pageSelec.mouseEnabled = false;
            GameProxy.robCityProxy.getGuildRobCityOneScoreList(RobCityStepOnePanel.PageSize, this._pageSelec.currentPage, false);
            return;
        }

        public updateMyGuildRank(arg1: int): void
        {
            this._myRank.htmlText = Language.getStringByParam(60928, arg1 > 0 ? arg1 : Language.getString(69857));
            this._myGuildRank.htmlText = Language.getStringByParam(60930, arg1 > 0 ? arg1 : " -- ");
            return;
        }

        public updateScoreList(arg1: DataProvider, arg2: int, arg3: int): void
        {
            this._list.dataProvider = arg1;
            this._pageSelec.maxPage = arg3 > 5 ? 5 : arg3;
            this._pageSelec.currentPage = arg2;
            this._pageSelec.mouseEnabled = true;
            return;
        }

        public /* override */ updateStatus(arg1: int): void
        {
            this._pageSelec.mouseEnabled = true;
            var loc1=Cache.instance.robCity.robCityCopyOneInfo;
            if (loc1 && loc1.weekCount > 0 && loc1.score > 0) 
            {
                this._statusLabel.htmlText = Language.getStringByParam(60938, RemainTimeTool.getRemainTimeBySeconds(loc1.score / 1000, false, true));
            }
            else 
            {
                this._statusLabel.htmlText = Language.getString(80138);
            }
            if (loc1 && loc1.hasOpen) 
            {
                HighlightManager.instance.glowEffectButton(this._signBtn, true);
            }
            else 
            {
                HighlightManager.instance.glowEffectButton(this._signBtn, false);
            }
            return;
        }

        public static /* const */PageSize: int=10;

        /* internal */ /* var */_signBtn: GLoadedButton;

        /* internal */ /* var */_list: GTileList;

        /* internal */ /* var */_pageSelec: PageSelecter;

        /* internal */ /* var */_statusLabel: GTextFiled;

        /* internal */ /* var */_myRank: GTextFiled;

        /* internal */ /* var */_myGuildRank: GTextFiled;
    }
